package com.zjbti.commonview;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;


public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    Button button;
    Button button2;
    Button button3;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        //实现按钮1点击
        button=findViewById(R.id.button);
        button2=findViewById(R.id.button2);
        button3=findViewById(R.id.button3);
        button3.setOnClickListener(this);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                button.setText("按钮1已被点击了");
            }
        });
    }
    //实现按钮2点击
    public void click(View view) {
        button2.setText("按钮2已被点击了");
    }
    //实现按钮3点击
        public void onClick(View view){
        if (view.getId()==R.id.button3)
            button3.setText("按钮3被点击了");
        }
}